<html>
<head>
<!--
 | jsMath-controls.html
 |
 | Part of the jsMath package for mathematics on the web.
 | 
 | This file handles the details of the jsMath control panels
 | 
 | ---------------------------------------------------------------------
 | 
 | Copyright 2004-2007 by Davide P. Cervone
 |
 | Licensed under the Apache License, Version 2.0 (the "License");
 | you may not use this file except in compliance with the License.
 | You may obtain a copy of the License at
 |
 |     http://www.apache.org/licenses/LICENSE-2.0
 |
 | Unless required by applicable law or agreed to in writing, software
 | distributed under the License is distributed on an "AS IS" BASIS,
 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | See the License for the specific language governing permissions and
 | limitations under the License.
-->
</head>
<body>

<script>
var showWarning = 0;
var domain = document.domain || "";
var mustPost = ((domain == "" || domain == "localhost") && window.postMessage);
while (!window.jsMath && !showWarning) {
  try {
    window.jsMath = window.parent.jsMath;
    if (!window.jsMath) {throw "no jsMath";}
  } catch (err) {
    showWarning = 1; pageDomain = '';
    try {pageDomain = document.domain} catch (err) {}
    //
    // MSIE on Mac can't change document.domain, and 'try' won't
    //   catch the error (Grrr!) so don't even attempt it.
    //
    if (pageDomain.match(/\..*\./) &&
        (navigator.appName != 'Microsoft Internet Explorer' ||
         !navigator.platform.match(/Mac/) || !navigator.userProfile || !document.all)) {
      try {
        document.domain = pageDomain.replace(/^[^.]*\./,'');
        showWarning = 0;
      } catch(err) {}
    }
  }
}

function Warning () {
  alert(
    "jsMath can't open the control panel, since jsMath was not " +
    "obtained from a server that is in the same domain as the " +
    "page that loaded it."
  );
}

if (showWarning) {
  if (!mustPost) setTimeout("Warning()",1);
} else {
  var debug = window.parent.debug;
  var show = window.parent.show;
}
</SCRIPT>

<SCRIPT ID="jsMath_script">
if (window.jsMath) {

jsMath.Add(jsMath.Controls,{

  loaded: 1,

  mainLabels: {
    print: 'Print',  reload: 'Reload', local: 'Go Local', global: 'Go Global',
    ctrls: 'Controls', opts: 'Options', done: 'Done'
  },
  optionLabels: {back: 'Back', done: 'Done'},

  Close: function () {
    this.panel.style.display = "none";
    jsMath.Element("button").style.display = (this.cookie.button ? "block" : "none");
    if (jsMath.document.location.protocol == 'file:' && jsMath.Global.islocal) return;
    for (var id in {scale:1, scaleImg:1, font:1, print:1, printwarn:1,
                    stayhires:1, autofont:1, alpha:1, tex2math:1, global:1}) {
      if (this.cookie[id] && this.cookie[id] != this.oldCookie[id] &&
          this.oldCookie[id] != null) {
        this.Reload();
        return;
      }
    }
  },

  Main: function () {
    this.oldCookie = {}; jsMath.Add(this.oldCookie,this.cookie);
    this.GetPanel("main");

    jsMath.Element("_version").innerHTML = jsMath.version;

    jsMath.Element("_fontType").innerHTML =
      ({tex:"TeX",
        image:"Image",
        symbol:"Image symbol",
        unicode:"Unicode"})[this.cookie.font];

     jsMath.Element("_mailto").href =
       "mailto:dpvc@union.edu?subject=Bug Report for jsMath "
           + jsMath.version + " (using " + jsMath.browser
           + " in " + this.cookie.font + " mode)";

    if (this.cookie.print ||
       (this.cookie.font != 'image' && this.cookie.font != 'symbol'))
         {jsMath.Element("_resolution").disabled = true}

    if (jsMath.Global.isLocal) {
      jsMath.Element("_ctrls").disabled = true;
    } else {
      this.cookie.hiddenGlobal = jsMath.Global.isHidden;
      jsMath.Element("_global").style.display = "none";
      jsMath.Element("_local").style.display = "";
      if (!jsMath.Global.isHidden || jsMath.noShowGlobal)
        {jsMath.Element("_ctrls").disabled = true}
    }
    if (jsMath.noChangeGlobal) {
      for (var id in {global:1, local:1, ctrls: 1})
        {jsMath.Element('_'+id).disabled = true}
    }
    if (!window.print) {jsMath.Element("_print").disabled = true}

    if (jsMath.Browser.safariButtonBug) {
      for (var id in this.mainLabels)
        {jsMath.Element('_'+id).value = this.mainLabels[id]}
    }

    this.panel.style.display = "block";
    this.openMain = 0;
  },

  Options: function () {
    this.GetPanel("options");
    jsMath.Element("_scale").value = this.cookie.scale;
    jsMath.Element("_keep").value = this.cookie.keep;
    jsMath.Element("_global").value = this.cookie.global;
    for (var id in {autofont:1, scaleImg:1, alpha:1, warn:1, printwarn: 1,
                    stayhires: 1, button:1, progress:1, asynch:1, blank:1, tex2math:1}) {
      if (this.cookie[id]) {jsMath.Element('_'+id).checked = true}
    }
    var font = jsMath.document.getElementsByName("jsMath__font");
    for (var i = 0; i < font.length; i++) {
      if ((font[i].value == 'tex' && jsMath.nofonts) ||
          ((font[i].value == 'symbol' || font[i].value == 'image') &&
             jsMath.noImgFonts)) {
        jsMath.Element('_'+font[i].value+"Text").className = "disabled";
        font[i].disabled = true;
      }
      else if (this.cookie.font == font[i].value) {font[i].checked = true}
    }
    if (jsMath.noImgFonts) {
      for (var id in {alpha:1, printwarn:1, stayhires:1}) {
        var obj = jsMath.Element("_"+id);
        obj.disabled = true;
        obj.parentNode.className = "disabled";
      }
    } else if (jsMath.Browser.imgScale != 1) {
      jsMath.Element("_alphaText").className = "disabled";
      jsMath.Element("_alpha").disabled = true;
    }
    if (jsMath.tex2math.Convert) {
      jsMath.Element("_separator").style.display = '';
      jsMath.Element("_tex2mathRow").style.display = '';
    }
    if (jsMath.noChangeGlobal) {
      jsMath.Element("_globalText").className = "disabled";
      jsMath.Element("_global").disabled = true;
    }
    if (jsMath.isCHMmode) {
      jsMath.Element("_asynchText").className  = "disabled";
      jsMath.Element("_asynch").disabled = true;
    }

    if (jsMath.Browser.safariButtonBug) {
      for (var id in this.optionLabels)
        {jsMath.Element('_'+id).value = this.optionLabels[id]}
    }

    this.panel.style.display = "block";

    if (jsMath.Browser.msieMoveButtonHack) {
      this.panel.style.left = "0px";
      this.panel.style.top = "0px";
      jsMath.Controls.MoveButton();
    }
  },

  HTML: {},  // storage for panels for Firefox3 in local mode

  GetPanel: function (name) {
    this.panel.innerHTML = ""; // for MSIE on the Mac
    var html = this.HTML[name];
    if (html == null) {html = document.getElementById("jsMath_"+name).innerHTML}
    this.panel.innerHTML = html;
  },

  SaveOptions: function (close) {
    this.cookie.scale = jsMath.Element("_scale").value;
    var font = jsMath.document.getElementsByName("jsMath__font");
    for (var i = 0; i < font.length; i++) 
      {if (font[i].checked) {this.cookie.font = font[i].value}}
    for (var id in {autofont:1, scaleImg:1, alpha:1, warn:1, printwarn: 1,
                    stayhires: 1, button:1, progress:1, asynch:1, blank:1, tex2math:1}) {
      if (this.cookie[id] != null) {
        this.cookie[id] = jsMath.Element('_'+id).checked ? 1: 0;
      }
    }
    this.cookie.keep = jsMath.Element("_keep").value;
    this.cookie.global = jsMath.Element("_global").value;
    this.cookie.print = this.cookie.stayhires;
    this.SetCookie(1);
    if (close) {this.Close()} else {this.Main()}
  },

  PrintResolution: function () {
    this.cookie.print = 1;
    this.SetCookie(1);
    this.Close();
  },

  Print: function () {
    this.Close();
    jsMath.window.print();
  },

  GoGlobal: function () {
    this.cookie.global = "always";
    jsMath.Global.GoGlobal(this.SetCookie(2));
  },
  GoLocal: function () {jsMath.Global.GoLocal()},

  ShowControls: function () {
    this.Close();
    jsMath.Global.Show();
  },

  NoAuto: function () {jsMath.Element("_autofont").checked = false}

});

jsMath.Add(jsMath.Post.Commands,{
  PAN: function (message) {jsMath.Controls.HTML.main = message},
  OPT: function (message) {jsMath.Controls.HTML.options = message},

  PST: function (message) {
    jsMath.Controls.Main();
    jsMath.Script.endLoad();
    jsMath.Message.doClear();
  }
});

}
</script>

<!------------------------------------------------------------>

<div id="jsMath_main">
<div style="text-align:center">
<b style="font-size:133%">jsMath v<span ID="jsMath__version"></span></b>
(<span id="jsMath__fontType">type</span> fonts)
[<a target="_blank" href="http://www.math.union.edu/locate/jsMath/users/main.html">help</a>]
<p style="margin-bottom:0px">
<table border="0" cellspacing="0" cellpadding="0" style="margin:0px">
<tr valign="middle"><td align="center">
<table border="0" cellspacing="0" cellpadding="0">
<tr><td class="infoLink" align="left">&#8226; <a target="_blank" href="http://www.math.union.edu/locate/jsMath/users/quickstart.html">Quick Start</a></td></tr>
<tr><td class="infoLink" align="left">&#8226; <a target="_blank" href="http://www.math.union.edu/locate/jsMath/users/fonts.html">Missing Fonts</a></td></tr>
<tr><td class="infoLink" align="left">&#8226; <a target="_blank" href="http://www.math.union.edu/locate/jsMath/users/printing.html">Printing Issues</a></td></tr>
<tr><td height="5"></td></tr>
<tr><td class="infoLink" align="left">&#8226; <a target="_blank" href="http://www.math.union.edu/locate/jsMath">Home Page</a></td></tr>
<tr><td class="infoLink" align="left">&#8226; <a target="_blank" href="http://www.math.union.edu/locate/jsMath/users/">Documentation</a></td></tr>
<tr><td class="infoLink" align="left">&#8226; <a target="_blank" href="https://sourceforge.net/forum/?group_id=172663">User Community</a></td></tr>
<tr><td height="5"></td></tr>
<tr><td class="infoLink" align="left">&#8226; <a target="_blank" href="http://www.math.union.edu/locate/jsMath/bugs.html">Known Bugs</a></td></tr>
<tr><td class="infoLink" align="left">&#8226; <a id="jsMath__mailto" href="mailto:dpvc@union.edu?subject=jsMath Bug Report">Report a Bug</a></td></tr>
<tr><td height="5"></td></tr>
<tr><td class="infoLink" align="left">&#8226; <a target="_blank" href="http://www.math.union.edu/locate/jsMath/jsMath/COPYING.txt">License</a></td></tr>
</table>
</td>

<td style="width:1em">&nbsp;</td>

<td align="center">
<table border="0" cellspacing="0" cellpadding="0">
<tr><td align="center" colspan="3">
<input type="button" id="jsMath__resolution" value="Hi-Res Fonts for Printing"
       style="width:18em" onclick="jsMath.Controls.PrintResolution()" />
</td></tr>

<tr><td height="8"></td></tr>

<tr valign="bottom"><td align="left">
<input type="button" value="Print" id="jsMath__print" style="width:8em" onclick="jsMath.Controls.Print()" /><br />
<input type="button" value="Reload" id="jsMath__reload" style="width:8em" style="width:8em" onclick="jsMath.window.location.reload()" /><br />
</td><td>
&nbsp;
</td><td align="right">
<input type="button" value="Go Global" id="jsMath__global" style="width:8em" onclick="jsMath.Controls.GoGlobal()"a /><!--
--><input type="button" value="Go Local" id="jsMath__local" style="width:8em;display:none" onclick="jsMath.Controls.GoLocal()" /><br />
<input type="button" value="Controls" id="jsMath__ctrls" style="width:8em" onclick="jsMath.Controls.ShowControls()" /><br/>
</td></tr>

<tr><td height="8"></td></tr>

<tr valign="bottom"><td align="left">
<input type="button" value="Options" id="jsMath__opts" style="width:8em" onclick="jsMath.Controls.Options()" /><br/>
</td><td>
&nbsp;
</td><td align="right">
<input type="button" value="Done" id="jsMath__done" style="width:8em" onclick="jsMath.Controls.Close()" />
</td></tr>
</table></td></tr>

<tr><td height="10"></td></tr>

<tr>
<td colspan="3" align="center" style="width:26em">
<i style="font-size:75%">Click the jsMath button or <nobr>ALT-click</nobr>
on mathematics to reopen this panel.</i>
</td></tr>

</table></p>
</div>
</div>

<!------------------------------------------------------------>

<div id="jsMath_options">
<div style="text-align:center">
<b style="font-size:133%">jsMath Options</b>
[<a target="_blank" href="http://www.math.union.edu/locate/jsMath/users/help.html">help</a>]
<p>
<form action="javascript:" style="margin:0px">
<table border="0" cellspacing="0" cellpadding="0">
<tr valign="top"><td>

<table border="0" cellspacing="0" cellpadding="0" style="text-align:left">

<tr><td><input type="checkbox" id="jsMath__autofont"  value="1" /> Autoselect best font</td></tr>
<tr><td><input type="checkbox" id="jsMath__warn"      value="1" /> Show font warnings</td></tr>
<tr><td><input type="checkbox" id="jsMath__alpha"     value="1" /> Use image alpha channels</td></tr>
<tr><td><input type="checkbox" id="jsMath__printwarn" value="1" /> Print image-font help</td></tr>
<tr><td><input type="checkbox" id="jsMath__stayhires" value="1" /> Always use hi-res fonts</td></tr>

<tr><td style="height:.8em"></td></tr>

<tr><td><input type="checkbox" id="jsMath__progress" value="1" /> Show progress messages</td></tr>
<tr><td><input type="checkbox" id="jsMath__asynch"   value="1" /> <span id="jsMath__asynchText">Force asynchronous processing</span></td></tr>
<tr><td><input type="checkbox" id="jsMath__blank"    value="1" /> Don't show page until complete</td></tr>
<tr><td><input type="checkbox" id="jsMath__button"   value="1" /> Show jsMath button</td></tr>

<tr id="jsMath__separator" style="display:none"><td style="height:.8em"></td></tr>

<tr id="jsMath__tex2mathRow" style="display:none"><td><input type="checkbox" id="jsMath__tex2math" value="1" /> Enable <code>tex2math</code> plug-in</td></tr>

</td></tr>
</table>
</td>
<td style="width:2em"></td>
<td>

<table border="0" cellspacing="0" cellpadding="0" style="text-align:left">
<tr><td>Scale all mathematics to <input type="text" id="jsMath__scale" value="100" size="3" />%</td></tr>

<tr><td style="height:.5em"></td></tr>

<tr><td><input type="radio" name="jsMath__font" value="tex" onclick="jsMath.Controls.NoAuto()" />
<span id="jsMath__texText">Use native TeX fonts</span>
<small>(<a target="_blank" href="http://www.math.union.edu/locate/jsMath/download/jsMath-fonts.html">download</a>)</small>
</td></tr>
<tr><td><input type="radio" name="jsMath__font" value="image" onclick="jsMath.Controls.NoAuto()" />
<span id="jsMath__imageText">Use image fonts
<span id="jsMath__scaleImgText">(<input type="checkbox" id="jsMath__scaleImg" value="1" /> scalable)</span></span></td></tr>
<tr><td><input type="radio" name="jsMath__font" value="symbol" onclick="jsMath.Controls.NoAuto()" />
<span id="jsMath__symbolText">Use images for symbols only</span></td></tr>
<tr><td height="2"></td></tr>
<tr><td><input type="radio" name="jsMath__font" value="unicode" onclick="jsMath.Controls.NoAuto()" />
Use native Unicode fonts</td></tr>

<tr><td style="height:1em"></td></tr>

<tr><td align="center"><span id="jsMath__globalText">Use Global mode</span>
<select id="jsMath__global">
<option value="auto">when requested
<option value="always">always
<option value="never">never
</select>
</td></tr>
<tr><td height="3"></td></tr>
<tr><td>Save settings for
<select id="jsMath__keep">
<option value="0D">this session only
<option value="1D">1 day
<option value="2D">2 days
<option value="3D">3 days
<option value="1W">1 week
<option value="2W">2 weeks
<option value="1M">1 month
<option value="2M">2 months
<option value="3M">3 months
<option value="6M">6 months
<option value="1Y">1 year
<option value="5Y">5 years
</select>
</td></tr>

<tr><td style="height:1em"></td></tr>

</table>

<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td align="left">&nbsp;
<input type="button" value="Back" id="jsMath__back" style="width:8em" onclick="jsMath.Controls.SaveOptions(0)" />
&nbsp;&nbsp;
</td>
<td align="right">
<input type="button" value="Done" id="jsMath__done" style="width:8em" onclick="jsMath.Controls.SaveOptions(1)" />
&nbsp;
</td>
</tr>
</table>

</td></tr>

</table>
</form>
</div>
</div>
</p>

<!------------------------------------------------------------>

<script>
  if (showWarning) {
    if (mustPost) {
      var scr = document.getElementById("jsMath_script");
      window.parent.postMessage("jsMCP:SCR:"+scr.innerHTML,"*");
      var main = document.getElementById("jsMath_main");
      window.parent.postMessage("jsMCP:PAN:"+main.innerHTML,"*");
      var options = document.getElementById("jsMath_options");
      window.parent.postMessage("jsMCP:OPT:"+options.innerHTML,"*");
      window.parent.postMessage("jsMCP:PST:","*");
    }
  } else {
    jsMath.Controls.Main()
  }
</script>
<script>
  if (window.jsMath) {
    jsMath.Script.endLoad();
    jsMath.Message.doClear();
  }
</script>
</body>
</html>
